<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<style type="text/css">
			body {
				/*background-image: url(pic/1ty.png);*/
				/*animation: move 35s infinite linear;*/
				background-color: #FFFFFF;
			}
			
			.mui-content {
				background-color: initial;
				animation: move 35s infinite linear;
			}
			
			#logo {
				width: 240px;
				margin-top: 57px;
				margin-left: calc(50% - 120px);
			}
			
			#man,
			#pwd {
				/*width: 314px;*/
				background-color: initial;
				/*margin-left: 20%;*/
				width: 70%;
				float: left;
				/*height: 39px;*/
				margin-bottom: 0 !important;
				margin-top: 5px;
				border: none;
				/*margin-left: calc(50% - 157px);*/
				opacity: 0.7;
				border-radius: 3px;
			}
			
			#btn {
				width: 88%;
				height: 42px;
				border-radius: 0;
				margin-left: calc(50% - 157px);
				margin-top: 20px;
				font-size: 18px !important;
				background-color: #00baf7;
				border: 1px solid #00baf7;
				float: left;
			}
			
			@keyframes move {
				0% {
					background-position: -0px 0px;
				}
				50% {
					background-position: -470px 0px;
				}
				100% {
					background-position: -0px 0px;
				}
			}
			
			.line {
				width: 0px;
				height: 1px;
				margin-left: calc(50% - 157px);
				transition: 0.5s;
				background-color: #607EDF;
				position: absolute;
			}
			
			#shadow {
				position: fixed;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				background: #000000;
				z-index: -1;
				opacity: 0;
			}
			
			#topimg {
				width: 100%;
				height: 200px;
				background-image: url(pic/loginbg.jpg);
				background-size: 100%;
			}
			
			.input-item {
				width: 88%;
				margin-top: 10px;
				height: 44px;
				border: 1px solid #00baf7;
				margin-left: 6%;
			}
			
			.ii-club {
				float: left;
				width: 13%;
				height: 100%;
				background-color: #00baf7;
			}
			
			.ii-club img {
				width: 21px;
				margin-top: 9px;
				margin-left: calc(50% - 10px);
			}
			
			.ii-active {
				border: 1px solid #00baf7;
				background-color: #00BAF7;
			}
			
			.iic-input {
				margin-top: 0 !important;
				height: 42px !important;
			}
			
			#underimg {
				width: 100%;
				height: 5px;
				/*background-color: ;*/
				background: linear-gradient(to bottom, #cccccc, white);
			}
			
			#remanber {
				float: left;
				margin-top: 10px;
				margin-left: 20px;
			}
			
			#forget {
				float: right;
				margin-right: 20px;
				margin-top: 15px;
			}
			
			#retext {
				float: left;
				margin-top: 13px;
				font-size: 13px;
				margin-left: 5px;
				color: #CCCCCC;
			}
		</style>
	</head>

	<body id="boody">
		<div id="m-con" class="mui-content">
			<div id="topimg">

				<img id="logo" src="pic/forrepair.png" />
			</div>
			<!--<img id="underimg" src="pic/loginbg32.png"/>-->
			<div id="underimg">

			</div>
			<div style="margin-top: 50px;" class="input-item">
				<div class="ii-club">

					<img src="pic/man.png" />

				</div>
				<input class="iic-input" placeholder="学号/工号" id="man" type="text" name="0" id="" value="" />
			</div>
			<div style="padding-bottom: 0 !important;" class="input-item">
				<div class="ii-club">
					<img src="pic/pwd.png" />
				</div>
				<input class="iic-input" placeholder="输入密码" id="pwd" type="password" name="1" id="" value="" />
			</div>
			<div id="functiontext">
				<div id="remanber" class="mui-switch mui-switch-mini mui-switch-blue">
					<div class="mui-switch-handle"></div>
				</div>
				<label id="retext" for="remanber">记住密码</label>
				<p id="forget">忘记密码</p>
			</div>
			<button style="margin-top: 30px;" id="btn" type="button" class="mui-btn mui-btn-purple">登&nbsp;&nbsp;录</button>
		</div>
		<div id="shadow">

		</div>
		<script src="js/ajax.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init()
			window.onload = function() {
				if(localStorage.getItem("username")!=""&&localStorage.getItem("username")!=undefined&&localStorage.getItem("userpwd")!=""&&localStorage.getItem("userpwd")!=undefined){
					document.getElementById("man").value = localStorage.getItem("username")
					document.getElementById("pwd").value = localStorage.getItem("userpwd")
					document.getElementById("remanber").className="mui-switch mui-switch-mini mui-switch-blue mui-active";
				}else{
					document.getElementById("remanber").className="mui-switch mui-switch-mini mui-switch-blue";
					
				}
				document.getElementById("boody").style.height = window.screen.height + "px"
				localStorage.setItem("vesion", "1.0.7")

				function isAndroid_ios() {
					var u = navigator.userAgent,
						app = navigator.appVersion;
					var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
					var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
					return isAndroid == true ? true : false;
				}

				myajax.data = {}
				myajax.backfun = function(data) {
					if(data.data.latestVersion != "1.0.7") { //版本号
						document.getElementById("btn").disabled = "disabled"
						console.log(localStorage.getItem("datemark"))
						if(isAndroid_ios()) {
							mui.confirm('有最新的可用版本,不更新将导致无法登录应用', '版本', ['暂不更新', '更新'], function(e) {
								if(e.index == 1) {
									mui.toast('开始下载,请耐心等待')
									plus.nativeUI.showWaiting()
									var dtask = plus.downloader.createDownload(myajax.baseurl + "files/download/nepurepair.apk", {}, function(d, status) {
										console.log(d.filename)
										if(status == 200) {
											mui.toast('下载完成')
											plus.runtime.openFile("file:///storage/emulated/0/Android/data/io.dcloud.H55B1D1AE/" + d.filename.substring(1))
										} else {
											mui.toast('下载失败，请检查配置')
										}
									});
									dtask.start();
								} else {
									plus.runtime.quit()
								}

							}, 'div')
						} else {
							mui.alert('该应用有更新可用请去App Store中查看', '提示', '我知道了', function(e) {
								if(e.index == 0) {

									plus.runtime.quit();
								}

							}, 'div')
						}

					}
				}
				myajax.get("sys/info/2") //维修端用
			}
			mui.back = function() {
				plus.runtime.quit();
			};
			mui('body').on('tap', '#btn', function() {
				var man = document.getElementById("man").value
				var pwd = document.getElementById("pwd").value
				if(man == "" || pwd == "") {
					mui.toast('您有信息为空')
				} else {
					mui.ajax(myajax.baseurl + "user/token", {
						data: {
							"universityId": document.getElementById("man").value,
							"password": document.getElementById("pwd").value,
							"type":"worker"
						},
						headers: {
							'Content-Type': 'application/json'
						},
						dataType: 'json', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						success: function(data) {
							if(data["code"] == 200) {

								localStorage.setItem("token", data["data"])
								location.href = "repair_list.html"
								var isActive = document.getElementById("remanber").classList.contains("mui-active");
								if(isActive) {
									//									console.log("打开状态");
									localStorage.setItem("username", document.getElementById("man").value)
									localStorage.setItem("userpwd", document.getElementById("pwd").value)
								} else {
									//									console.log("关闭状态");
									localStorage.setItem("username", "")
									localStorage.setItem("userpwd", "")
								}

							} else {
								if(data["code"] == 400) {
									mui.toast('用户名或密码错误')
								} else {
									mui.toast("服务器在开小差，请稍后再试")
								}
							}
						},
						error: function(xhr, type, errorThrown) {
							mui.toast('网络连接失败')
						}
					});
				}

			})
		</script>
	</body>

</html>